import React, { Component } from 'react'
import { NavBar } from 'antd-mobile'
import "./Home.less"
import Banner from './component/Banner/Banner';
import Groupon from "./component/Groupon/Groupon"
import { SearchList } from "../../components/SearchList"
import { SearchBar } from 'antd-mobile';
import { reqGetgroupon, reqGetnew } from "../../http/api"
import a from "../../assets/img/1.png"
import b from "../../assets/img/2.png"
import c from "../../assets/img/3.png"
import d from "../../assets/img/4.png"
import e from "../../assets/img/5.png"
export default class Home extends Component {
    constructor() {
        super()
        this.state = {
            getnewList: [],
            getGroupon: []

        }
    }
    async componentDidMount() {
        let res = await reqGetnew()
        this.setState({
            getnewList: res.data.list
        })
        let res2 = await reqGetgroupon()
        this.setState({
            getGroupon: res2.data.list
        })
    }
    render() {
        let { getnewList, getGroupon } = this.state
        return (
            <div className="home">
                <NavBar>首页</NavBar>
                <SearchBar placeholder="Search" maxLength={8} onSubmit={() => this.props.history.push("/search")} />

                {/* <SearchList></SearchList> */}

                <div className="new">
                    新人专享
                </div>
                {/* 新人专享 */}
                {getnewList.length > 0 ? <Banner getnewList={getnewList}></Banner> : null}
                <div className="lie">
                    <div className="nav">
                        <img src={a} alt="" />
                        <span>限时秒杀</span>
                    </div>
                    <div className="nav">
                        <img src={b} alt="" />
                        <span>限时秒杀</span>
                    </div>
                    <div className="nav">
                        <img src={c} alt="" />
                        <span>限时秒杀</span>
                    </div>
                    <div className="nav">
                        <img src={d} alt="" />
                        <span>限时秒杀</span>
                    </div>
                    <div className="nav">
                        <img src={e} alt="" />
                        <span>限时秒杀</span>
                    </div>
                   
                </div>
                {/* <div className="new">
                    万人团
                </div> */}
                {/* 万人团 */}
                {getGroupon.length > 0 ? <Groupon getGroupon={getGroupon}></Groupon> : null}

            </div>
        )
    }
}
